{% extends 'base.html' %}

{% block title %}{% if template %}编辑工作流模板{% else %}新建工作流模板{% endif %}{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h2>
                    <i class="fas fa-sitemap me-2"></i>
                    {% if template %}编辑工作流模板{% else %}新建工作流模板{% endif %}
                </h2>
                <a href="{% url 'assets:workflow_template_list' %}" class="btn btn-secondary">
                    <i class="fas fa-arrow-left me-1"></i>返回列表
                </a>
            </div>

            <div class="card">
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        <div class="mb-3">
                            <label for="id_name" class="form-label">模板名称</label>
                            {{ form.name }}
                        </div>
                        <div class="mb-3">
                            <label for="id_template_type" class="form-label">模板类型</label>
                            {{ form.template_type }}
                        </div>
                        <div class="mb-3">
                            <label for="id_description" class="form-label">描述</label>
                            {{ form.description }}
                        </div>
                        <div class="mb-3">
                            <label for="id_workflow_definition" class="form-label">流程定义 (JSON格式)</label>
                            {{ form.workflow_definition }}
                            <div class="form-text">
                                请输入有效的JSON格式。例如：<br>
                                <pre><code>{
    "steps": [
        {
            "id": "step1",
            "name": "经理审批",
            "type": "manual",
            "assignee_group": "Manager"
        },
        {
            "id": "step2",
            "name": "IT部门处理",
            "type": "manual",
            "assignee_group": "IT"
        }
    ]
}</code></pre>
                            </div>
                        </div>
                        <div class="form-check mb-3">
                            {{ form.is_active }}
                            <label class="form-check-label" for="id_is_active">是否启用</label>
                        </div>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
